<template>
  <el-card>
    <el-form
      style="display: flex; justify-content: space-around"
      :disabled="isShow"
    >
      <el-form-item label="一级分类" style="width: 30%">
        <el-select v-model="CategoryStore.c1Id" @change="getC2">
          <el-option
            v-for="c1 in CategoryStore.c1Arr"
            :key="c1.id"
            :label="c1.name"
            :value="c1.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类" style="width: 30%">
        <el-select
          v-model="CategoryStore.c2Id"
          @change="getC3"
          :disabled="!CategoryStore.c1Id"
        >
          <el-option
            v-for="c2 in CategoryStore.c2Arr"
            :key="c2.id"
            :label="c2.name"
            :value="c2.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类" style="width: 30%">
        <el-select v-model="CategoryStore.c3Id" :disabled="!CategoryStore.c2Id">
          <el-option
            v-for="item in CategoryStore.c3Arr"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script lang="ts" setup name="index">
import { onMounted } from 'vue'
import useCategoryStore from '@/store/module/category'
let CategoryStore = useCategoryStore()
defineProps(['isShow'])
onMounted(() => getC1())
const getC1 = () => {
  CategoryStore.getC1()
}
const getC2 = () => {
  CategoryStore.c2Id = ''
  CategoryStore.c3Id = ''
  CategoryStore.c3Arr = []
  CategoryStore.getC2(CategoryStore.c1Id)
}
const getC3 = () => {
  CategoryStore.c3Id = ''
  CategoryStore.getC3(CategoryStore.c2Id)
}
</script>
<style scoped lang="less"></style>
